<?php
namespace frontend\controllers;

use Yii;
use yii\web\Controller;

/**
 * Site controller
 */
class AuthController extends Controller
{

    /**
     * @inheritdoc
     */
    public function actions()
    {
        return [
            'error' => [
                'class' => 'yii\web\ErrorAction',
            ],
        ];
    }

    /**
     * Displays homepage.
     *
     * @return mixed
     */
    public function actionIndex()
    {
        $session = Yii::$app->session;
        $access_token = Yii::$app->wechat->getOauthAccessToken();
        if($access_token){
            $session['access_token'] = $access_token;
            return $this->redirect('/index.php?r=' . $session['route_url']);
            exit;
        }
    }

}
